package com.huoyun.car.action;

import com.huoyun.base.action.BaseAction;
import com.huoyun.car.bean.CarPubInfo;
import com.huoyun.car.service.CarPubInfoService;
import com.huoyun.cargo.bean.CargoInfo;
import com.huoyun.cargo.service.CargoService;
import com.huoyun.common.bean.BidInfo;
import com.huoyun.common.service.BidInfoService;

public class InviteCarAction extends BaseAction{
	private CargoService cargoService;
	private CarPubInfoService carPubInfoService;
	private BidInfoService bidInfoService;
	
	private String bidPrice;
	private int goodsId;
	private long pubId;
	
	private CarPubInfo carPubInfo;
	private CargoInfo cargoInfo;

	
	
	public String preInviteCar(){
		System.out.println("goodsId="+goodsId);
		cargoInfo=cargoService.getCargoInfoById(goodsId);
		carPubInfo=carPubInfoService.getCarPubInfoById(pubId);
		//double value=(cargoInfo.getCost()/cargoInfo.getWeight())*carPubInfo.getLoadMax();
		//bidPrice=Math.round(value*100)/100.0;
		System.out.println(carPubInfo.getId()+" carId="+carPubInfo.getCarId());
		return SUCCESS;
	}

	public String inviteCar(){
		
		BidInfo bidInfo=new BidInfo();
		bidInfo.setCarId(carPubInfo.getCarId());
		//bidInfo.setGoodsId(cargoInfo.getId());
		bidInfo.setPrice(bidPrice);
		bidInfo.setStatus(1);
		bidInfoService.saveBidInfo(bidInfo);
		return SUCCESS;
	}

	public CargoService getCargoService() {
		return cargoService;
	}

	public void setCargoService(CargoService cargoService) {
		this.cargoService = cargoService;
	}

	public CarPubInfoService getCarPubInfoService() {
		return carPubInfoService;
	}

	public void setCarPubInfoService(CarPubInfoService carPubInfoService) {
		this.carPubInfoService = carPubInfoService;
	}

	public BidInfoService getBidInfoService() {
		return bidInfoService;
	}

	public void setBidInfoService(BidInfoService bidInfoService) {
		this.bidInfoService = bidInfoService;
	}

	public String getBidPrice() {
		return bidPrice;
	}

	public void setBidPrice(String bidPrice) {
		this.bidPrice = bidPrice;
	}

	public int getGoodsId() {
		return goodsId;
	}



	public void setGoodsId(int goodsId) {
		this.goodsId = goodsId;
	}



	public long getPubId() {
		return pubId;
	}



	public void setPubId(long pubId) {
		this.pubId = pubId;
	}

	public CarPubInfo getCarPubInfo() {
		return carPubInfo;
	}

	public void setCarPubInfo(CarPubInfo carPubInfo) {
		this.carPubInfo = carPubInfo;
	}

	public CargoInfo getCargoInfo() {
		return cargoInfo;
	}

	public void setCargoInfo(CargoInfo cargoInfo) {
		this.cargoInfo = cargoInfo;
	}

}
